<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="/css/common.css" />
<link rel="stylesheet" type="text/css" href="/bootstrap-3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/css/flatpickr.min.css" />
<link rel="stylesheet" type="text/css" href="/css/font-awesome.css" />
<link rel="stylesheet" type="text/css" href="/dialog/css/dialog.css" />

<script src="/js/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="/js/google-maps.js" type="text/javascript" charset="utf-8"></script>
<script src="/js/jquery.validate.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/dialog/js/dialog.js" type="text/javascript" charset="utf-8"></script>
<script src="/js/jquery.form.js"></script>
<script src="/js/common.js"></script>
<script src="/js/flatpickr.js" type="text/javascript" charset="utf-8"></script>
<script src="/js/messages_zh.min.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
	<!--顶部导航 -->
		<nav class="topNavItemBox">
			<div id="ItemBox">
				<div class="title">肉品溯源管理系统</div>
			</div>
		</nav>
		<!-- 左侧导航 -->

	<#include "left.ftl"/>
	<!-- 新增公司信息 -->
	<div class="page_main">
		<h3>新增养殖信息</h3><span class="add_link"><a href="/admin/Feeding/findByCondition">查询养殖信息></a></span>
		<br />
		<div class="page_content">

			<form id="quarantine_addform" action="/admin/Feeding/addFeeding"
				method="post">
				<ul>
					<li><label class="labelBeforinput">*企业编号</label><input name="compid"  class="bigInputtext" required data-rule-notZero="true" />
					<li><label class="labelBeforinput">*区域编号</label><input name="areaid"  class="bigInputtext" required data-rule-notZero="true"/>
					<li><label class="labelBeforinput">*生猪编号</label><input name="animalid" id="purGid" onblur="checkPig()" class="bigInputtext" required type="text" /></li>
					<li><label class="labelBeforinput">*饲料编号</label><select name="feedid"  class="bigInputtext" required data-rule-notZero="true">
							<option value="0">请选择</option>
							<#list feedsList as feed>
							    <option value="${feed.feedid}">${feed.feedname}</option>
							</#list>
							</select>
					</li>
					<li><label class="labelBeforinput">*饲料单位</label><input type="text" name="foodunit" class="bigInputtext" required/></li>
					<li><label class="labelBeforinput">*饲料用量</label><input name="foodamount" type="text" class="bigInputtext" required /></li>
					<li><label class="labelBeforinput">*喂养时间</label><input type="text" name="feedingtime" id="feedingTime" class="bigInputtext" required/></li>
					<li><label class="labelBeforinput">*执行人编号</label><input name="employeeid" type="text" class="bigInputtext" data-rule-notZero="true" required /></li>
					<li><label class="labelBeforinput">备注</label><input name="remark" type="text" class="bigInputtext"  /></li>

					<li><input type="submit" value="添加记录"
						style="margin-left: 170px; width: 200px;" /></li>
				</ul>
			</form>
		</div>
		<div class="footer">
				<div class="footer_lineone">
					<span id="logo"></span>肉品溯源管理系统 
					<span class="footer_lineoneSpan"><a href="aboutus.html">关于我们</a></span>
					<span class="footer_lineoneSpan"><a target="_blank" href="http://www.cfsiw.com/">食品安全信息</a></span> 
					<span class="footer_lineoneSpan"><a href="suggestionAdd.ftl">联系我们</a></span>
				</div>
				<div class="footer_linetwo">
					 &copy;2017广东技术师范学院
				</div>
			</div>
	</div>
</body>
<script>
	$(function() {
		//初始化侧边栏
		$(".vertical-nav").verticalnav({
			speed : 400,
			align : "left"
		});

		//时间控制器
		$("#feedingTime").flatpickr();




		//表单提交
		$("#quarantine_addform")
				.ajaxForm(
					{
						success : function(data) {
							var str = null;
							var msg = null;
							if (data.msg=="1") {
								str = "success";
								msg = "饲养信息录入成功";
								$.dialog({
									type : 'info',
									contentHtml : '<img class="info-icon" src="dialog/images/icon/'+str+'.png" alt="'+msg+'" /><p class="info-text">'
											+ msg + '</p>',
									autoClose:1000
								});
							setInterval(function(){
								location.href="/admin/Feeding/findByCondition";
							},1000);
								
							} else {
								str = "fail";
								msg = data.msg;
								$.dialog({
									type : 'info',
									contentHtml : '<img class="info-icon" src="dialog/images/icon/'+str+'.png" alt="'+msg+'" />',
									autoClose:1000
								});
							}
							}
						});
	});


    //检验出场生猪是否有有出场检验
    function checkPig() {
        var pigID = $("#purGid").val();
        $.get("/admin/ProInspect/checkPur?pid="+pigID,function (data) {
            var str = null;
            var msg = null;
            if (data.msg == 1) {
                str = "false";
                msg = "该生猪编号不存在";
                $.dialog({
                    type: 'info',
                    contentHtml: '<img class="info-icon" src="dialog/images/icon/' + str + '.png" /><p class="info-text">' + msg + '</p>',
                    autoClose: 3000
                });
                $("#purcid").val("");
            } else if (data.msg == 2) {
                str = "false";
                msg = "该生猪未出场检验，不可出场";
                $.dialog({
                    type: 'info',
                    contentHtml: '<img class="info-icon" src="dialog/images/icon/' + str + '.png" /><p class="info-text">' + msg + '</p>',
                    autoClose: 3000
                });
                $("#purcid").val("");
            }
            else {
                str = "success";
                msg = "生猪信息合法";
                $.dialog({
                    type: 'info',
                    contentHtml: '<img class="info-icon" src="dialog/images/icon/' + str + '.png"  /><p class="info-text">' + msg + '</p>',
                    autoClose: 3000
                });
            }
        });
    }
</script>

</html>